﻿-- =============================================
-- Author:		<Author,XFL>
-- Create date: <Create Date,20120112>
-- Description:	<Description,获取个人出勤记录>
-- =============================================
CREATE PROCEDURE [dbo].[proc_Employee_Attendance_GetList_GR]
	-- Add the parameters for the stored procedure here
	(
		@StartIndex int,
		@EndIndex int,
		@TypeId int,	
		@Month nvarchar(7),	
		@UserName nvarchar(50)
	)
AS
	Begin
		
									
		;WITH list As(Select ROW_NUMBER() OVER (ORDER BY Employee_Attendance.Id DESC)AS Row, 
			Id,
			UserName,
			EName,
			CompanyId,
			(Select c.CompanyName From Company c Where c.Id=CompanyId) as CompanyName,
			TypeId,
			--(Select top 1 eat.Title From Employee_Attendance_Type eat Where eat.Id=TypeId) as TypeName,
			t_TypeName as TypeName,
			KouKuanAmount, 
			KouKuanFromDate,
			KouKuanToDate,
			'' as Description,
			(Select top 1 e.EName From Employee e Where e.UserName=CreateName) as CreateName,
			CreateDate,
			Wage_FF
		From
			Employee_Attendance
		Where 
			UserName=@UserName	and (@TypeId=0 or TypeId=@TypeId) and (  Convert(nchar(7),KouKuanToDate,120)=@Month)
		)
		Select *,(select count(0) from list)  AS Count_Sum From list Where Row between @StartIndex and @EndIndex 						    
	End
	RETURN
